package com.itheima.exception;

import com.itheima.pojo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice   //等价于@ControllerAdvice + @ResponseBody 用来捕获controller的所有异常
public class GlobalHandlerException {
    @ExceptionHandler(Exception.class)  //指定要处理哪种异常
    public Result doException(Exception e){
        log.error(e.getMessage());
        return Result.error("出错了，请联系管理员！！！");
    }
}
